<?php
?>

<div class="form-horizontal adminex-form">
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label form-label-key">机构:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['institution_name'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">充值金额:</label>
        <label class="col-lg-9 control-label form-label-value">￥<?= $item['amount'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">充值方式:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['mode'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">付款单位:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['payment_name'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">收款单位(人):</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['receivable_name'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">收款银行:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['receivable_bank'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">收款账号:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['receivable_account'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">状态:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['status_name'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label col-lg-3">备注:</label>
        <label class="col-lg-9 control-label form-label-value"><?= $item['remark'] ?></label>
    </div>
    <div class="form-group">
        <label class="col-lg-3 col-sm-3 control-label">附件:</label>
        <?php
        if (isset($item['attachments'])) {
            foreach ($item['attachments'] as $attch) {
                echo '<button class="btn btn-link" type="button" onclick="javascript:window.open(\'' . $attch['url'] . '\')">' . $attch['name'] . '</button>';
            }
        }
        ?>
    </div>
    <div class="form-group">
        <div class="pull-right">
            <?php
            $hasPermission = \app\models\Permission::hasPermission('finance', 'approve-recharge-handler');
            if ($hasPermission == true) {
                switch ($item['status']) {
                    case 1:
                        echo "<button class='btn btn-success' id='btnApproveSuccess' data-recharge-id='{$item['id']}'>通过审核</button>";
                        echo "<button class='btn btn-danger' id='btnApproveFailed' data-recharge-id='{$item['id']}'>审核失败</button>";
                        break;
                }
            }
            ?>
        </div>
    </div>
</div>

<script type="application/javascript">
    $('#btnApproveSuccess').click(function () {
        var data = {};
        data.recharge_id = $(this).attr('data-recharge-id');
        data.recharge_status = 11;
        requestJson('approve-recharge-handler', data, true, function (responseData) {
            $('#addModal').modal('hide');
            if (responseData.status == 0) {
                window.location.reload();
            } else {
                alert(responseData.message);
            }
        });
    });

    $('#btnApproveFailed').click(function () {
        var data = {};
        data.recharge_id = $(this).attr('data-recharge-id');
        data.recharge_status = 12;
        requestJson('approve-recharge-handler', data, true, function (responseData) {
            $('#addModal').modal('hide');
            if (responseData.status == 0) {
                window.location.reload();
            } else {
                alert(responseData.message);
            }
        });
    });
</script>
